
function Split(szFullString, szSeparator)  
local nFindStartIndex = 1  
local nSplitIndex = 1  
local nSplitArray = {}  
while true do  
   local nFindLastIndex = string.find(szFullString, szSeparator, nFindStartIndex)  
   if not nFindLastIndex then  
    nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, string.len(szFullString))  
    break  
   end  
   nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, nFindLastIndex - 1)  
   nFindStartIndex = nFindLastIndex + string.len(szSeparator)  
   nSplitIndex = nSplitIndex + 1  
end  
return nSplitArray  
end  

-- 主入口函数
function main()
	notifyMessage('Hello World')
	local data = httpGet('http://git.oschina.net/michael/lll/raw/master/README.md'); 
	local list = Split(data, "|")
	
	for i, v in pairs(list) do 
			
		local tmpList = Split(v,"#")
		local tmpUrl = ""
		local tmpFileName = ""		
		for i1, v1 in pairs(tmpList) do 	
			if i1 == 1 then 
				tmpUrl = v1
			else 
				tmpFileName = v1				
			end 			
		end		

		notifyMessage("开始下载"..tmpUrl..tmpFileName)
		local netData = httpGet(tmpUrl)
		
		local path = ("var/touchelf/scripts/"..tmpFileName)
		local file = io.open(path, "w+")
		file:write(netData)
			
		file:close()
		notifyMessage (netData)	
		mSleep(1000)		
 		notifyMessage("下载"..tmpFileName.."完成")

	end		
end
